package oj;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Day43F {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        while(sc.hasNext()){
            int n=Integer.parseInt(sc.nextLine());
            ArrayList<String> list=new ArrayList<>();
            for(int i=0;i<n;i++){
                String str=sc.nextLine();
                char[] ch=str.toCharArray();
                StringBuilder sb=new StringBuilder();
                for(char c:ch){
                    if(c>='0' && c<='9'){
                        sb.append(c);
                    }else if(c=='-'){
                        continue;
                    }else if(c>='A' && c<='C'){
                        sb.append(2);
                    }else if(c>='D' && c<='F'){
                        sb.append(3);
                    }else if(c>='G' && c<='I'){
                        sb.append(4);
                    }else if(c>='J' && c<='L'){
                        sb.append(5);
                    }else if(c>='M' &&c<='O'){
                        sb.append(6);
                    }else if(c>='P' &&c<='S'){
                        sb.append(7);
                    }else if(c>='T' &&c<='V'){
                        sb.append(8);
                    }else if(c>='W' &&c<='Z'){
                        sb.append(9);
                    }
                }
                sb.insert(3,"-");
                if(!list.contains(sb.toString())){
                    list.add(sb.toString());
                }
            }
            Collections.sort(list);
            for(String str:list){
                System.out.println(str);
            }
            System.out.println();
        }
    }

}
